import { Component, OnInit } from '@angular/core';
import { HttpClient } from '@angular/common/http';

@Component({
  selector: 'app-shop-msg',
  templateUrl: './shop-msg.component.html',
  styleUrls: ['./shop-msg.component.css']
})
export class ShopMsgComponent implements OnInit {
  // 获取商品信息\直降的显示控制
  public getShops: any[] = [];
  private index: any;
  // 声明http
  constructor(public http: HttpClient) { }

  ngOnInit() {

    // 直降的显示控制
    const overflow = document.getElementById('direct-low');
    if (this.index % 2 === 0) {
      overflow.style.display = 'block';
      console.log('qwer');
    }
    // overflow.style.display = 'block';
    // 添加轮播图的请求
    // const addCarousel = 'http://192.168.2.228:8080/goods/add';
    // this.http.post(addCarousel , {
    //   headers: new HttpHeaders({
    //     file : '',
    //     rotation_link : '',
    //     rotation_state : ''
    //   })
    // }).subscribe((response) => {
    //   console.log(response);
    // });

    //  获取所有商品信息
    const getShops = 'http://192.168.2.228:8080/goods/list';
    this.http.get(getShops).subscribe((response: any) => {
      console.log(response);
      this.getShops = response.data.list;
      // this.index = response.data.list;
    });

    //  获取所有商品分类
    const getShopsSort = 'http://192.168.2.228:8080/sort/list';
    this.http.get(getShopsSort).subscribe((response: any) => {
      console.log(response);
      // this.list = response.data.list;
    });


    //  获取分类名
    const getSortDetail = 'http://192.168.2.228:8080/sort/detail';
    this.http.get(getSortDetail).subscribe((response: any) => {
      console.log(response);
      // this.list = response.data.list;
    });

    //  获取订单中商品详情
    const getOrderDetail = 'http://192.168.2.228:8080/ordergoods/detail';
    this.http.get(getOrderDetail).subscribe((response: any) => {
      console.log(response);
      // this.list = response.data.list;
    });
  }

}
